<template>
  <div id="app">
    <!-- template_1 -->
    <!-- <ul>
      <li><a href="/#/films">电影</a></li>
      <li><a href="/#/cinemas">影院</a></li>
      <li><a href="/#/center">我的</a></li>
    </ul> -->

    <!-- template_2 -->
    <!-- <ul>
      <li>
        <router-link to="/films" active-class="app_highlight">电影</router-link>
      </li>
      <li>
        <router-link to="/cinemas" active-class="app_highlight">影院</router-link>
      </li>
      <li>
        <router-link to="/center" active-class="app_highlight">我的</router-link>
      </li>
    </ul> -->
    <transition name="router-transition" mode="out-in">
      <router-view />
    </transition>
    <tabbar ref="mytabbar" v-if="$store.state.isTabbarShow"></tabbar>
  </div>
</template>

<script>
import tabbar from '@/components/Tabbar.vue'

export default {
  components: {
    tabbar
  },
  mounted () {
    if (this.$store.state.isTabbarShow) {
      // 获取组件tabbar的高度
      console.log(
        '获取组件tabbar的高度=================',
        this.$refs.mytabbar.$el.offsetHeight
      )
    }
  }

  // --------------------------------script_1--------------------------------
  // mounted () {
  //   this.changeHighlight()
  // },
  // updated () {
  //   // 监听hash路由的路径切换
  //   window.onhashchange = () => {
  //     console.log('路径改变了')
  //     this.changeHighlight()
  //   }
  // },
  // methods: {
  //   changeHighlight () {
  //     // 获取hash路由
  //     const urlSuffix = location.hash.slice(location.hash.lastIndexOf('/') + 1)
  //     if (urlSuffix === 'films') {
  //       document.querySelectorAll('a')[0].style.color = 'rgb(93, 93, 231)'
  //       document.querySelectorAll('a')[1].style.color = 'rgb(90, 168, 199)'
  //       document.querySelectorAll('a')[2].style.color = 'rgb(90, 168, 199)'
  //     } else if (urlSuffix === 'cinemas') {
  //       document.querySelectorAll('a')[0].style.color = 'rgb(90, 168, 199)'
  //       document.querySelectorAll('a')[1].style.color = 'rgb(93, 93, 231)'
  //       document.querySelectorAll('a')[2].style.color = 'rgb(90, 168, 199)'
  //     } else if (urlSuffix === 'center') {
  //       document.querySelectorAll('a')[0].style.color = 'rgb(90, 168, 199)'
  //       document.querySelectorAll('a')[1].style.color = 'rgb(90, 168, 199)'
  //       document.querySelectorAll('a')[2].style.color = 'rgb(93, 93, 231)'
  //     }
  //   }
  // }
}
</script>

<style lang="scss">
* {
  margin: 0;
  padding: 0;
  /* 禁用双击缩放功能，这个功能禁用之后，300ms延迟也不存在了 */
  touch-action: manipulation;
  /* 不能使用 touch-action: none; 会禁用浏览器的触摸行为，导致浏览器无法滑动 */
}

html,
body {
  width: 100%;
  height: 100%;
}

ul,
li {
  list-style: none;
}

a {
  text-decoration: none;
}

#app {
  padding-bottom: 49px;
}

// .move-enter-active {
//   animation: movepage .5s;
// }
// .move-leave-active {
//   animation: movepage .5s reverse;
// }
// @keyframes movepage {
//   0% {
//     opacity: 0;
//     transform: translateY(30px);
//   }
//   100% {
//     opacity: 1;
//     transform: translateY(0px);
//   }
// }

.slide-transition {
  transition: all 0.4s ease;
}

.slide-enter {
  transform: translate3d(0, 100%, 0);
}

.slide-leave {
  transform: translate3d(0, -100%, 0);
}

.router-transition-enter-active {
  transition: all 0.3s ease;
}

.router-transition-leave-active {
  transition: all 0.5s ease;
}

.router-transition-enter,
.router-transition-leave-active {
  transform: translateY(20px);
  opacity: 0;
}

// --------------------------------style_1--------------------------------
// ul, li {
//   list-style: none;
// }
// ul {
//   width: 200px;
//   display: flex;
//   justify-content: space-between;
// }
// a{
//   color: rgb(90, 168, 199);
//   text-decoration: none;
// }
// a:hover {
//   color: rgb(93, 93, 231);
//   text-decoration: underline;
// }

// --------------------------------style_2--------------------------------
// .app_highlight {
//   color: red;
// }
</style>
